package com.itlong.cloud.enumerate.oldapp;

import com.fasterxml.jackson.annotation.JsonCreator;

public enum Code {
	SUCCESS("0","成功"),
	ERROR("1","失败"),
	NOT_PARAM("2","缺少必要参数"),
	PARAM_ERR("3","参数错误"),
	OPER_ERR("4","操作失败，请检验数据"),
	UPDATE_ERROR("5","更新失败"),
	DELETE_ERROR("6","删除失败"),
	APP_UPDATE("7","当前版本不支持，请至商店下载最新版本"),
	LOGIN_ERROR("100","账号或者密码错误"),
	NOT_LOGIN("101","未登录"),
	NOT_PERMISSION("102","没有权限"),
	EXIST_PHONENO("103","手机号码已经存在"),
	SMSCODE_ERR("104","短信验证码错误"),
	EXIST_USERNAME("105","用户昵称已经存在"),
	NOT_AUTH("106","该手机号码无权限注册"),
	PSWD_ERR("107","登录密码错误"),
	EXIST_AUTH_PHONENO("108","该手机号码已经授权"),
	USER_STATUSERR("109","该用户已经失效，请联系管理员"),
	NOT_FOUNDUSER("110","未找到该用户"),
	NOT_FOUNDPHONE("111","该手机号码未注册"),
	ADDAUTH_ERROR("112","一级授权人不能被授权"),
	TOKEN_ERR("250","登录过期,请重新登录"),
	ERR_OTHER("999","未知错误"),
	YKL_NOLOGIN("1001","开启失败"),
	PROJECT_NAME_EXIST("118","您的小区名称已添加,不可重名"),
	USER_PROJECT_EXIST("113","您的小区已添加,不可重复添加"),
	USER_AUTH_BEYOND("114","您允许授权的人数已满，请联系小区物业"),
	PROJECT_AUTH_REFUSE("115","项目已禁用，不可获取密钥"),
	PROJECT_REFUSE("116","项目已禁用，无法进行操作"),
	APP_DEVELOP_ERR("117","开发者账号或密钥错误"),
	USER_REFUSE("118","账号已禁用，无权操作"),
	NOT_BACK_MANAGE("119","非系统用户，无权登录"),
	NOT_ENGINEER("120","非工程人员，无权登录"),
	PROPERTY_MANAGER_EXIST("121","此项目物业管理员账号已分配，不可重复分配！"),
	PROJECT_EXIST("122","此项目已存在，不可重复添加！"),
	UPDATE_VERSION_REMIND("123","请先升级至最新版本！"),
	VERIFYCODE_ERR("124","图片验证码错误"),
	UPLOAD_FILE_ERR("125","文件上传错误，请重新上传"),
	PAPER_NUMBER_EXIST("127","说明书编号已存在,请重新填写"),
	PAPER_NOT_EXIST("128","说明书不存在,请联系旺龙客服!"),
	PID_EXIST("129","产品型号已存在，不可重复添加!"),
	SDK_PROJECTID_ERR("126","缺少项目编号"),
	CARD_NUM_INVALID_ERR("130","软卡号不合法"),
	PHONE_NO_INVALID_ERR("131","手机号不合法"),
	USER_STATUS_INVALID_ERR("132","状态不合法"),

	PROJECT_NOT_EXIST("133","项目不存在"),
	DEVICE_UNIQUE_EMPTY_ERR("133","设备唯一码不能为空"),
	DEVICE_NAME_EMPTY_ERR("134","设备名称不能为空")
	;
	private String code ;
	private String msg;

	/**
	 * <desc>
	 *     	反序列化时的 初始化函数，入参为 对应该枚举的 json值
	 * </desc>
	 * @param code
	 * @return
	 * @author Jiaqi.X
	 * @createDate 2017/12/22
	 */
	@JsonCreator
	public static Code getItem(String code){
		for(Code item : values()){
			if(item.getCode().equals(code)){
				return item;
			}
		}
		return Enum.valueOf(Code.class,code);
	}

	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	private Code(String code,String msg){
		this.setCode(code);
		this.setMsg(msg);
	}
	
	@Override
	public String toString() {
		return code;
	}
}
